import matplotlib.pyplot as plt
import numpy as np


def control_panel_state_chart():
    # 模拟输入密码尝试次数
    attempts = np.arange(0, 10)

    password_status = np.zeros_like(attempts)
    lock_status = np.zeros_like(attempts)
    system_function_status = np.zeros_like(attempts)

    password = "1234"  # 假设设置的密码
    input_password = ""

    for i, attempt in enumerate(attempts):
        if password_status[i - 1] == 0:  # 还未验证密码或处于初始状态
            input_password += "1"  # 这里简单模拟每次输入一个字符，实际应根据输入获取
            if len(input_password) == 4:
                if input_password == password:
                    password_status[i] = 1
                    system_function_status[i] = 1
                else:
                    password_status[i] = -1
                    if password_status.count(-1) == 3:
                        lock_status[i] = 1

        if lock_status[i] == 1:
            if i - lock_status.index(1) > 120:
                lock_status[i] = 0
                password_status[i] = 0
                input_password = ""

    plt.plot(attempts, password_status, label='Password Status (Correct: 1, Incorrect: -1, Initial: 0)')
    plt.plot(attempts, lock_status * 100, label='Lock Status (Locked: 100, Unlocked: 0)')
    plt.plot(attempts, system_function_status * 200, label='System Function Status (Entered: 200, Not Entered: 0)')

    plt.xlabel('Password Attempts')
    plt.ylabel('Status')
    plt.title('SafeHome Control Panel State Chart')
    plt.legend()
    plt.show()